import 'package:flutter_network/service_method.dart';
import 'package:wallet_utils/report_widget/base/callback/base_callback.dart';
import 'package:wallet_utils/report_widget/base/callback/net_request_utils.dart';

import '../bean/iconDetailBean.dart';
import 'home_url.dart';

class HomeApi {
  //查询用户状态 用于首页UI配置
  static obtainIndexInfoV3(String cityName,BaseCallback callback) async {
    Map<String, dynamic> paramsMap = {
      "cityName": cityName,
    };
    return NetRequestUtils.request(
        future: HttpRequest().requestPost(
          HomeUrl.obtainIndexInfoV3,
          params: paramsMap,
        ),
        callback: callback);
  }
  static obtainIndexInfo(BaseCallback callback) async {
    return NetRequestUtils.request(
        future: HttpRequest().requestGet(
          HomeUrl.obtainIndexInfo,
        ),
        callback: callback);
  }
  //首页金刚区
  static showPage(int page, BaseCallback callback) {
    Map<String, dynamic> paramsMap = {
      "page": page,
    };
    return NetRequestUtils.request(
        future: HttpRequest().requestGetPath(
          HomeUrl.showPage,
          pathParams: paramsMap,
        ),
        callback: callback);
  }

  //获取用户审核结果
  static obtainAuditResultInfo(BaseCallback callback) {
    return NetRequestUtils.request(
        future: HttpRequest().requestGet(
          HomeUrl.obtainAuditResultInfo,
        ),
        callback: callback);
  }

  //获取用户认证步骤
  static checkAuthStep(BaseCallback callback) {
    return NetRequestUtils.request(
        future: HttpRequest().requestGet(
          HomeUrl.checkAuthStep,
        ),
        callback: callback);
  }

  //进件控制页
  static channelIncomingControl(BaseCallback callback) {
    return NetRequestUtils.request(
        future: HttpRequest().requestGet(
          HomeUrl.channelIncomingControl,
        ),
        callback: callback);
  }

  //查询用户及进件所有信息
  static getAppUserInfoAll(BaseCallback callback) {
    return NetRequestUtils.request(
        future: HttpRequest().requestGet(
          HomeUrl.getAppUserInfoAll,
        ),
        callback: callback);
  }
  //进件信息详情信息接口（前置）
  static incomingDetail(IconDetailBean? bean, BaseCallback callback) {
    Map<String, dynamic> paramsMap = {
      "page": bean,
    };
    return NetRequestUtils.request(
        future: HttpRequest().requestPost(
          HomeUrl.incomingDetail,
          params: bean?.toJson(),
        ),
        callback: callback);
  }
  //进件信息详情信息接口（后置）
  static incomingDetailV2(IconDetailBean? bean, BaseCallback callback) async {
    Map<String, dynamic> paramsMap = {
      "page": bean,
    };
    // {"loanAmount":"1-5万","loanPeriod":null,"gpsCityName":"北京市","provinceId":"","cityId":"","dwellAddress":"","credit":"","jddept":null,"propertyItems":"","profession":"","job":"","marriage":"","education":"","loanPurpose":""}
    return  NetRequestUtils.request(
        future: HttpRequest().requestPost(
          HomeUrl.incomingDetailV2,
          params: bean?.toJson(),
        ),
        callback: callback);
  }

  static authIdCard(String realName, String idCard, String idCardPositive, String idCardNegative, String idCardPeriod,
      String nativePlace,String issuingAuth, String nation, BaseCallback callback) {
    Map<String, dynamic> paramsMap = {
      "realName": realName,
      "idCard": idCard,
      "idCardPositive": idCardPositive,
      "idCardNegative": idCardNegative,
      "idCardPeriod": idCardPeriod,
      "nativePlace": nativePlace,
      "issuingAuth":issuingAuth,
      "nation":nation,
    };
    return NetRequestUtils.request(
        future: HttpRequest().requestPost(
          HomeUrl.authIdCard,
          params: paramsMap,
        ),
        callback: callback);
  }

  static authIdCardAndPush(String realName, String idCard, String idCardPositive, String idCardNegative, String idCardPeriod,
      String nativePlace,String issuingAuth, String nation, BaseCallback callback) {
    Map<String, dynamic> paramsMap = {
      "realName": realName,
      "idCard": idCard,
      "idCardPositive": idCardPositive,
      "idCardNegative": idCardNegative,
      "idCardPeriod": idCardPeriod,
      "nativePlace": nativePlace,
      "issuingAuth":issuingAuth,
      "nation":nation,
    };
    return NetRequestUtils.request(
        future: HttpRequest().requestPost(
          HomeUrl.authIdCardAndPush,
          params: paramsMap,
        ),
        callback: callback);
  }

  static compareFaceV2(String faceUrl, BaseCallback callback) {
    Map<String, dynamic> paramsMap = {
      "faceUrl": faceUrl,
    };
    return NetRequestUtils.request(
        future: HttpRequest().requestPost(
          HomeUrl.compareFaceV2,
          params: paramsMap,
        ),
        callback: callback);
  }
  //PageNo取值：4：首页弹窗产品，5：进件页弹窗产品，6：审核页弹窗产品
  static getCpaPopList(int pageNo, BaseCallback callback) {
    Map<String, dynamic> paramsMap = {
      "pageNo": pageNo,
    };
    return NetRequestUtils.request(
        future: HttpRequest().requestGetPath(
          HomeUrl.getCpaPopList,
          pathParams: paramsMap,
        ),
        callback: callback);
  }

  static addLoanRecord(num productId,int showPage, BaseCallback callback) {
    Map<String, dynamic> paramsMap = {
      "productId": productId,
      'showPage': showPage,
    };
    return NetRequestUtils.request(
        future: HttpRequest().requestPost(
          HomeUrl.addLoanRecord,
          params: paramsMap,
        ),
        callback: callback);
  }

  static clickBannerRecord(num bannerId,num pageType, BaseCallback callback) {
    Map<String, dynamic> paramsMap = {
      "bannerId": bannerId,
      'pageType': pageType,
    };
    return NetRequestUtils.request(
        future: HttpRequest().requestPost(
          HomeUrl.clickBannerRecord,
          params: paramsMap,
        ),
        callback: callback);
  }
  //API机构和授权书
  static getUser2WhereApi(BaseCallback callback) {
    return NetRequestUtils.request(
        future: HttpRequest().requestGet(
          HomeUrl.getUser2WhereApi,
        ),
        callback: callback);
  }
}
